home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Games / NeXTmille / Source / Player.h < prev    next >
Text File  |  1991-01-11  |  8KB  |  175 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import <objc/Object.h>
  5. #import    <appkit/Matrix.h>
  6. #import    <appkit/Text.h>
  7. #import    <objc/List.h>
  8. #import    "CardsTracker.h"
  9. #import    "CardView.h"
  10. #import    "DistanceCardStackView.h"
  11. #import    "DrawPileStackView.h"
  12. #import    "HandTileView.h"
  13. #import    "SafetyStacksView.h"
  14. #import    "StackView.h"
  15.  
  16.  
  17. // There are two player objects in the game.  
  18. //    The player object and the game is designed for no more than two players.
  19. // 
  20. // There two key areas of interest of this object, they are the 
  21. //    the card:movedFrom:to: and playMove methods.
  22. // The card:movedFrom:to: method comes from the drag coordinator.  It is sent
  23. //    by the drag coordinator whenever a card is dragged from one pile to another.
  24. //    The card:movedFrom:to: method does some logic parsing and breaks the move down.
  25. //    It then calls another method, playCard:fromHandPile:toBattlePile: for example,
  26. //    to perform futher parsing and complete the move if appropriate.
  27. // The playMove method is sent to a Player object to compute and play a move.  This
  28. //    is the method sent to your opponent in response to your move.
  29.  
  30.  
  31. @interface Player:Object
  32. {
  33.  
  34.                                                 // All of the objects listed below are set by the .nib
  35.                                                 //    dearchiving method.
  36.     SafetyStacksView        *safetyPile;
  37.     Matrix                    *otherScoreMatrix,
  38.                             *mainScoreMatrix;
  39.     HandTileView            *handPile;
  40.     StackView                *battlePile,
  41.                             *speedPile,
  42.                             *discardPile;
  43.     DrawPileStackView        *drawPile;
  44.     DistanceCardStackView    *distancePile;
  45.     Text                    *messagesText;
  46.     id                         opponent;
  47.     id                        gameCoordinator;
  48.     CardsTracker            *cardsTracker;
  49.                                                 // These lists hold pointers to cards.  Therefore when the 
  50.                                                 //    lists are erased the objects aren't freed, simply the
  51.                                                 //    pointers to the objects are removed.
  52.                                                 // The safety and coup fouree lists hold the cards that are
  53.                                                 //    shown in the safety view.
  54.     List                    *safetyList,
  55.                             *coupFoureeList;
  56.                                                 // These variables hold the last known
  57.                                                 //    cards at the top of the speed and battle
  58.                                                 //    piles.  They are used for coup fouree detection.
  59.                                                 //    If we want to play a safety card that is
  60.                                                 //    a remedy for a hazard and the hazard wasn't
  61.                                                 //    then on the last play, then it is a
  62.                                                 //    coup fouree.
  63.     CardView                *lastBattleCard,
  64.                             *lastSpeedCard;
  65.                                                 // These are flags used by the player.  When the player
  66.                                                 //    moves a card, and the move is accespted, the cardWasPlayedFlag
  67.                                                 //    is set true. 
  68.                                                 // If a saftey card was played the safetyWasPlayedFlag flag is set
  69.                                                 //    true.
  70.     BOOL                    cardWasPlayedFlag,
  71.                             safetyWasPlayedFlag;
  72. }
  73.  
  74. +new;
  75. - free;
  76.                                                 // These methods set the outlets for instances of this
  77.                                                 //    class.
  78. - setSafetyPile:( SafetyStacksView * )anObject;
  79. - setHand:( HandTileView * )anObject;
  80. - setBattlePile:( StackView * )anObject;
  81. - setSpeedPile:( StackView * )anObject;
  82. - setDistancePile:( DistanceCardStackView * )anObject;
  83.  
  84.                                                 // These methods are usually called by the oppoent but sometimes
  85.                                                 //    by the player.  returns nil ( or an empty list) if no cards
  86.                                                 //    are in the pile.
  87. - ( CardView * )battleCard;
  88. - ( CardView * )speedCard;
  89. - ( List * )safetyCards;
  90.                                                 // This method is called by the player's safety view to determine
  91.                                                 //    if the card just added is a coup fouree.
  92. - ( BOOL )isCoupFouree:( CardView * )aCard;
  93.                                                 // These methods return various outlets of this object.
  94.                                                 //    These methods are usually called by the game coordinator.
  95. - ( SafetyStacksView * )safetyPile;
  96. - ( Matrix * )otherScoreMatrix;
  97. - ( Matrix * )mainScoreMatrix;
  98. - ( HandTileView * )handPile;
  99. - ( StackView * )battlePile;
  100. - ( DrawPileStackView * )drawPile;
  101. - ( StackView * )speedPile;
  102. - ( StackView * )discardPile;
  103. - ( DistanceCardStackView * )distancePile;
  104. - opponent;
  105.                                                 // These methods are usually called by the game coordinator
  106.                                                 //    during the course of the game.
  107.                                                 // Prepare for a new hand or game.  
  108. - newHand;
  109. - newGame;
  110.                                                 // Draw a card and place it in hand.
  111. - drawCard;
  112.                                                 // This message comes from the drag coordinator and is only
  113.                                                 //    sent to the "you" player.  That player must decide if the
  114.                                                 //    move is valid.  If valid it must disconnect then connect
  115.                                                 //    the card to the proper views.
  116. - card:( CardView * )aCard movedFrom:( CardHolder * )oldHolder to:( CardHolder * )newHolder;
  117. - playCard:( CardView * )aCard fromDrawPile:( CardHolder * )oldHolder    toHandPile:( CardHolder * )newHolder;
  118. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toDiscardPile:( CardHolder * )newHolder;
  119. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toSpeedPile:( CardHolder * )newHolder;
  120. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toBattlePile:( CardHolder * )newHolder;
  121. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toSafetyPile:( CardHolder * )newHolder;
  122. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toDistancePile:( CardHolder * )newHolder;
  123. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toOpponentBattlePile:( CardHolder * )newHolder;
  124. - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder    toOpponentSpeedPile:( CardHolder * )newHolder;
  125.  
  126.                                                 // Check to see of a distance card can be played.
  127. - ( BOOL )canPlayDistanceCard:( CardView * )aCard;
  128.                                                 // Does the player have the safety card?
  129. - ( BOOL )hasSafety:( int )aCard;
  130.                                                 // These methods are used to determine if the same
  131.                                                 //    player can play a distance card.  The methods also
  132.                                                 //    account for the player having the right-of-way
  133.                                                 //    safety card.
  134. - ( BOOL )battlePileAllowsMove;
  135. - ( BOOL )speedPileAllowsMove;
  136. - ( BOOL )speedPileAllowsMove:( CardView * )aCard;
  137.                                                 // Check to sum to see if it will end the hand or the game.
  138. - ( BOOL )sumWillEndHand:( int )aSum;
  139. - ( BOOL )sumWillExceedHand:( int )aSum ;
  140. - ( BOOL )sumWillEndGame:( int )aSum;
  141.                                                 // Returns wheather the player has drawn a card from the
  142.                                                 //    draw pile.  If he hasn't and the draw pile is empty then
  143.                                                 //    the draw is considered to have ocurred.
  144. - ( BOOL )cardDrawn;
  145.  
  146.                                                 // Completes the card move the player selected and
  147.                                                 //    any maintenence required.
  148. - completeMove:( CardView * )aCard from:( CardHolder * )oldHolder to:( CardHolder * )newHolder;
  149.                                                 // These methods are used to sum the player's hand
  150.                                                 //    and overall score respectivly.
  151. - sumHand;
  152. - sumOverall;
  153.                                                 // Message to the opponent to calculate and play his
  154.                                                 //    next move.
  155.                                                 // If you want to add intelligence to the computer
  156.                                                 //    algorithm then this is the method to examine.
  157. - playMove;
  158.                                                 // Can the player play a hand?
  159.                                                 // This is the player looking at himself.
  160. - ( BOOL )canPlay;
  161.                                                 // This is the opponent looking.  It's a
  162.                                                 //    guess.
  163. - ( BOOL )couldPlay;                        
  164.                                                 // Causes the player to play all of the
  165.                                                 //    safeties in its hand.  This is done at or 
  166.                                                 //    near the end of the game.
  167. - finishThoseSafeties;
  168.                                                 // Look at the card tracker and hand
  169.                                                 //    to determine the number of this type of card
  170.                                                 //    played.
  171. - ( int )numCardTypeObserved:( int )aCardType;
  172.  
  173.  
  174. @end
  175.